/*
 * @Author: wangyifei 844650674@qq.com
 * @Date: 2022-11-27 10:22:26
 * @LastEditors: wangyifei 844650674@qq.com
 * @LastEditTime: 2022-11-27 11:32:21
 * @FilePath: \management_system_template\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
import Layout from "../layout/Index.vue";
import Area from "../views/Area.vue";
import User from "../views/User.vue";
import HomaPage from "../views/HomaPage.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/layout",
    name: "Layout",
    component: Layout,
    redirect: "/homepage",
    children: [
      {
        path: "/homepage",
        component: HomaPage,
      },
      {
        path: "/area",
        component: Area,
      },
      {
        path: "/setting",
        component: User,
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

// router.beforeEach((to, from, next) => {
//   let token = Cookies.get('token');
//   if (to.name != 'Login') {
//     if (token) {
//       next();
//     } else {
//       next({
//         path: '/login'
//       });
//     }
//   } else {
//     if (token) {
//       next({
//         path: '/User'
//       });
//     } else {
//       next();
//     }
//   }
// })

export default router;
